package kmp;


public class RepeatMinimumLength {

    public static void main(String[] args) {
        s = "abcabcab".toCharArray();
        n = s.length;
        System.out.println(compute());
    }

    public static int MAXN = 100_0001;

    public static int[] next = new int[MAXN];

    public static int n;

    public static char[] s;


    public static int compute() {
        nextArray();

        return n - next[n];
    }

    private static void nextArray() {
        next[0] = -1;
        next[1] = 0;

        int i = 2, cn = 0;
        while (i <= n) {
            if (s[i - 1] == s[cn]) {
                next[i++] = ++cn;
            } else if (cn > 0) {
                cn = next[cn];
            } else {
                next[i++] = 0;
            }
        }
    }
}
